package com.mxnet.chongjin.supoman.utils;

import android.content.Context;
import android.os.Looper;
import android.widget.Toast;

/**
 * author: Administrator
 * email: lcj270018655@163.com
 * date: 2018/5/4
 */

public class ToastUtils {
    private static Toast toast;

    public static void showToast(Context context, String content) {
        try {
            if (toast == null) {
                toast = Toast.makeText(context,
                        content,
                        Toast.LENGTH_SHORT);
            } else {
                toast.setText(content);
            }
            toast.show();
        }
        catch (Exception e)
        {
            if(Looper.myLooper()==null) {
                Looper.prepare();
            }
            if (toast == null) {
                toast = Toast.makeText(context,
                        content,
                        Toast.LENGTH_SHORT);
            } else {
                toast.setText(content);
            }
            toast.show();
            Looper.loop();

        }
    }
}
